import 'dart:convert';
import 'dart:ffi';
import 'dart:math';

import 'package:dio/dio.dart';
import 'http_network.dart';
import '../model/response_data.dart';

class NetworkStartConfig {
  List<Interceptor> interceptors = <Interceptor>[];

  NetworkStartConfig.init() {
    interceptors.add(RequestInterceptor());
    interceptors.add(ResponsetInterceptor());
    HttpManager.manager.addInterceptors(interceptors);
  }
}

class RequestInterceptor extends Interceptor {
  @override
  void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
    // TODO: implement onRequest
    super.onRequest(options, handler);

  }
}

class ResponsetInterceptor extends Interceptor {
  @override
  void onResponse(Response response, ResponseInterceptorHandler handler) {
    // TODO: implement onResponse
    super.onResponse(response, handler);

    response.data = SLRequestData.create(response.data['code'].toString(),
        response.data['message'], response.data['data']);
  }
}
